import json
import requests


def test_get():
    """
    测试请求报文中添加params参数，查看响应报文体变化
    :return:
    """
    url = "https://httpbin.ceshiren.com/get"
    params = {"name": "wwl"}
    r = requests.get(url, params=params)
    # 打印响应报文数据
    res_data = json.dumps(r.json(), indent=2)
    print(res_data)
    # 断言：请求成功
    assert r.status_code == 200
    assert r.json()["args"]["name"] == "wwl"
    
   
    
def test_post():
    """
    测试数据格式为 json,查看响应报文体变化
    :return:
    """
    url = "https://httpbin.ceshiren.com/post"
    data = {"username":"wwl", "password":"pwd123"}
    r = requests.post(url, json=data)
    # 打印响应报文数据
    res_data = json.dumps(r.json(), indent=2)
    print(res_data)
    # 断言：请求成功
    assert r.status_code == 200
    assert r.json()["json"]["username"] == "wwl"
